
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package twoTeam;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;
import javax.swing.JPanel;

/**
 *
 * @author uhgy3k
 */
public class Gradiente extends JPanel {
    int h,w,t;
    float matriz[][];
    int color;
    Gradiente(int n, int m,int l, int c, float[][] mat) {
        h = n;
        w = m;
        t = l;
        Random ran = new Random();
        matriz = mat;
        color = c;
    }
    
    @Override
    public void paintComponent( Graphics g)
    {
        super.paintComponent(g);        
        for(int x = 0; x < matriz.length; x++) {
            for(int y = 0; y < matriz[x].length; y++) {
                switch(color) {
                    case 0:
                        g.setColor(new Color(1,0,0,matriz[x][y]));
                        break;
                    case 1:
                        g.setColor(new Color(0,1,0,matriz[x][y]));
                        break;
                    case 2:        
                        try {
                        g.setColor(new Color(0,0,1,matriz[x][y]));
                        } catch(Exception e) {
                            System.out.println(matriz[x][y]);
                        }
                            
                        break;
                }
                g.fillRect(y*t, x*t, t, t);
            }
        }
    }
    
}